<cfcomponent output="false">

	<cffunction name="GetFoodDriveById" output="false" access="remote">
		<cfargument name="id" required="true" />
 		<cfreturn createObject("component", "FoodDriveDAO").read(arguments.id)>
	</cffunction>
	
	<cffunction name="GetAllFoodDrives" output="false" access="remote" returntype="FoodDrive[]">
		<cfset var qRead="">
		<cfset var obj = "">
		<cfset var fooddrives = arrayNew(1)>

		<cfquery username="#request.username#" password="#request.password#" name="qRead" datasource="nwharvest">
			select ID
			from FOODDRIVES
		</cfquery>

		<cfloop query="qRead">
		<cfscript>
			obj = createObject("component", "FoodDriveDAO").read(qRead.ID);
			ArrayAppend(fooddrives, obj);
		</cfscript>
		</cfloop>
		<cfreturn fooddrives>
	</cffunction>	
	
	<cffunction name="SaveFoodDrive" output="false" access="remote">
		<cfargument name="obj" required="true" />
 		<cfscript>
			if( obj.ID eq 0 )
			{
				return createObject("component", "FoodDriveDAO").create(arguments.obj);
			} else 
			{
				return createObject("component", "FoodDriveDAO").update(arguments.obj);
			}
		</cfscript>
	</cffunction>	
	
	<cffunction name="GetFoodDriveByManagerID" output="false" access="remote">
		<cfargument name="id" required="true" />
		<cfset var fd = GetFoodDriveById(arguments.id) />
 		<cfreturn createObject("component", "FoodDriveDAO").read(fd.id)>
	</cffunction>	

	<cffunction name="DeleteFoodDrive" output="false" access="remote">
		<cfargument name="id" required="true" />
		<cfset var obj = GetFoodDriveById(arguments.id)>
		<cfset createObject("component", "FoodDriveDAO").delete(obj)>
	</cffunction>

</cfcomponent>